# -*- coding: utf-8 -*-

from django.db import models

# Create your models here.
class JobInfo(models.Model):
    # 创建自增的一个主键
    id = models.AutoField('id', primary_key=True)
    title = models.CharField(verbose_name='岗位名字', max_length=255, default='')
    address = models.CharField(verbose_name='省会', max_length=255, default='')
    type = models.CharField(verbose_name='职业', max_length=255, default='')
    educational = models.CharField(verbose_name='学历', max_length=255, default='')
    workExperience = models.CharField(verbose_name='工作经验', max_length=255, default='')
    workTag = models.CharField(verbose_name='工作标签', max_length=1024, default='')
    salary = models.CharField(verbose_name='薪资', max_length=255, default='')
    salaryMonth = models.CharField(verbose_name='年终奖', max_length=255, default='')
    companyTags = models.CharField(verbose_name='公司福利', max_length=2048, default='')
    hrWork = models.CharField(verbose_name='人事职位', max_length=255, default='')
    hrName = models.CharField(verbose_name='人事名字', max_length=255, default='')
    pratice = models.BooleanField(verbose_name='是否为实习单位', max_length=255, default='')
    companyTitle = models.CharField(verbose_name='公司名称', max_length=255, default='')
    companyAvatar = models.CharField(verbose_name='公司头像', max_length=255, default='')
    companyNature = models.CharField(verbose_name='公司性质', max_length=255, default='')
    companyStatus = models.CharField(verbose_name='公司状态', max_length=255, default='')
    companyPeople = models.CharField(verbose_name='公司人数', max_length=255, default='')
    detailUrl = models.CharField(verbose_name='详情地址', max_length=1024, default='')
    companyUrl = models.CharField(verbose_name='公司详情地址', max_length=1024, default='')
    dist = models.CharField(verbose_name='行政区', max_length=255, default='')
    createTime = models.DateField(verbose_name='创建时间', auto_now_add=True)

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'job_info'
        # verbose_name = '职位数据表'
        # verbose_name_plural = verbose_name


class Users(models.Model):
    id = models.AutoField('id', primary_key=True)
    username = models.CharField(verbose_name='用户名', max_length=255, default='')
    password = models.CharField(verbose_name='密码', max_length=255, default='')
    educational = models.CharField(verbose_name='学历', max_length=255, default='')
    workExperience = models.CharField(verbose_name='工作经验', max_length=255, default='')
    address = models.CharField(verbose_name='意向城市', max_length=255, default='')
    work = models.CharField(verbose_name='意向岗位', max_length=255, default='')
    avatar = models.FileField(verbose_name='用户头像', upload_to='avatar', default='avatar/default.png')
    createTime = models.DateField(verbose_name='创建时间', auto_now_add=True)

    def __str__(self):
        return self.username

    class Meta:
        db_table = 'users'
        # verbose_name = '用户表'
        # verbose_name_plural = verbose_name


class History(models.Model):
    id = models.AutoField('id', primary_key=True)
    job = models.ForeignKey(JobInfo, on_delete=models.CASCADE)
    user = models.ForeignKey(Users, on_delete=models.CASCADE)
    count = models.IntegerField(verbose_name='点击次数', default=1)
    createTime = models.DateField(verbose_name='创建时间', auto_now_add=True)

    def __str__(self):
        return str(self.id)

    class Meta:
        db_table = 'history'
        # verbose_name = '历史记录'
        # verbose_name_plural = verbose_name